home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2004 April / Gamestar_61_2004-04_dvdb.iso / DVDStar / Editace / hltp.exe / {app} / Source Code / Half-Life Model Viewer / src / studio.h < prev    next >
C/C++ Source or Header  |  1999-05-04  |  7KB  |  351 lines

  1. /***
  2. *
  3. *    Copyright (c) 1998, Valve LLC. All rights reserved.
  4. *    
  5. *    This product contains software technology licensed from Id 
  6. *    Software, Inc. ("Id Technology").  Id Technology (c) 1996 Id Software, Inc. 
  7. *    All Rights Reserved.
  8. *
  9. ****/
  10.  
  11.  
  12.  
  13.  
  14. #ifndef _STUDIO_H_
  15. #define _STUDIO_H_
  16.  
  17. /*
  18. ==============================================================================
  19.  
  20. STUDIO MODELS
  21.  
  22. Studio models are position independent, so the cache manager can move them.
  23. ==============================================================================
  24. */
  25.  
  26.  
  27. #define MAXSTUDIOTRIANGLES    20000    // TODO: tune this
  28. #define MAXSTUDIOVERTS        2048    // TODO: tune this
  29. #define MAXSTUDIOSEQUENCES    256        // total animation sequences
  30. #define MAXSTUDIOSKINS        100        // total textures
  31. #define MAXSTUDIOSRCBONES    512        // bones allowed at source movement
  32. #define MAXSTUDIOBONES        128        // total bones actually used
  33. #define MAXSTUDIOMODELS        32        // sub-models per model
  34. #define MAXSTUDIOBODYPARTS    32
  35. #define MAXSTUDIOGROUPS        4
  36. #define MAXSTUDIOANIMATIONS    512        // per sequence
  37. #define MAXSTUDIOMESHES        256
  38. #define MAXSTUDIOEVENTS        1024
  39. #define MAXSTUDIOPIVOTS        256
  40. #define MAXSTUDIOCONTROLLERS 8
  41.  
  42. typedef struct 
  43. {
  44.     int                    id;
  45.     int                    version;
  46.  
  47.     char                name[64];
  48.     int                    length;
  49.  
  50.     vec3_t                eyeposition;    // ideal eye position
  51.     vec3_t                min;            // ideal movement hull size
  52.     vec3_t                max;            
  53.  
  54.     vec3_t                bbmin;            // clipping bounding box
  55.     vec3_t                bbmax;        
  56.  
  57.     int                    flags;
  58.  
  59.     int                    numbones;            // bones
  60.     int                    boneindex;
  61.  
  62.     int                    numbonecontrollers;        // bone controllers
  63.     int                    bonecontrollerindex;
  64.  
  65.     int                    numhitboxes;            // complex bounding boxes
  66.     int                    hitboxindex;            
  67.     
  68.     int                    numseq;                // animation sequences
  69.     int                    seqindex;
  70.  
  71.     int                    numseqgroups;        // demand loaded sequences
  72.     int                    seqgroupindex;
  73.  
  74.     int                    numtextures;        // raw textures
  75.     int                    textureindex;
  76.     int                    texturedataindex;
  77.  
  78.     int                    numskinref;            // replaceable textures
  79.     int                    numskinfamilies;
  80.     int                    skinindex;
  81.  
  82.     int                    numbodyparts;        
  83.     int                    bodypartindex;
  84.  
  85.     int                    numattachments;        // queryable attachable points
  86.     int                    attachmentindex;
  87.  
  88.     int                    soundtable;
  89.     int                    soundindex;
  90.     int                    soundgroups;
  91.     int                    soundgroupindex;
  92.  
  93.     int                    numtransitions;        // animation node to animation node transition graph
  94.     int                    transitionindex;
  95. } studiohdr_t;
  96.  
  97. // header for demand loaded sequence group data
  98. typedef struct 
  99. {
  100.     int                    id;
  101.     int                    version;
  102.  
  103.     char                name[64];
  104.     int                    length;
  105. } studioseqhdr_t;
  106.  
  107. // bones
  108. typedef struct 
  109. {
  110.     char                name[32];    // bone name for symbolic links
  111.     int                     parent;        // parent bone
  112.     int                    flags;        // ??
  113.     int                    bonecontroller[6];    // bone controller index, -1 == none
  114.     float                value[6];    // default DoF values
  115.     float                scale[6];   // scale for delta DoF values
  116. } mstudiobone_t;
  117.  
  118.  
  119. // bone controllers
  120. typedef struct 
  121. {
  122.     int                    bone;    // -1 == 0
  123.     int                    type;    // X, Y, Z, XR, YR, ZR, M
  124.     float                start;
  125.     float                end;
  126.     int                    rest;    // byte index value at rest
  127.     int                    index;    // 0-3 user set controller, 4 mouth
  128. } mstudiobonecontroller_t;
  129.  
  130. // intersection boxes
  131. typedef struct
  132. {
  133.     int                    bone;
  134.     int                    group;            // intersection group
  135.     vec3_t                bbmin;        // bounding box
  136.     vec3_t                bbmax;        
  137. } mstudiobbox_t;
  138.  
  139. #ifndef ZONE_H
  140. typedef void *cache_user_t;
  141. #endif
  142.  
  143. // demand loaded sequence groups
  144. typedef struct
  145. {
  146.     char                label[32];    // textual name
  147.     char                name[64];    // file name
  148.     cache_user_t        cache;        // cache index pointer
  149.     int                    data;        // hack for group 0
  150. } mstudioseqgroup_t;
  151.  
  152. // sequence descriptions
  153. typedef struct
  154. {
  155.     char                label[32];    // sequence label
  156.  
  157.     float                fps;        // frames per second    
  158.     int                    flags;        // looping/non-looping flags
  159.  
  160.     int                    activity;
  161.     int                    actweight;
  162.  
  163.     int                    numevents;
  164.     int                    eventindex;
  165.  
  166.     int                    numframes;    // number of frames per sequence
  167.  
  168.     int                    numpivots;    // number of foot pivots
  169.     int                    pivotindex;
  170.  
  171.     int                    motiontype;    
  172.     int                    motionbone;
  173.     vec3_t                linearmovement;
  174.     int                    automoveposindex;
  175.     int                    automoveangleindex;
  176.  
  177.     vec3_t                bbmin;        // per sequence bounding box
  178.     vec3_t                bbmax;        
  179.  
  180.     int                    numblends;
  181.     int                    animindex;        // mstudioanim_t pointer relative to start of sequence group data
  182.                                         // [blend][bone][X, Y, Z, XR, YR, ZR]
  183.  
  184.     int                    blendtype[2];    // X, Y, Z, XR, YR, ZR
  185.     float                blendstart[2];    // starting value
  186.     float                blendend[2];    // ending value
  187.     int                    blendparent;
  188.  
  189.     int                    seqgroup;        // sequence group for demand loading
  190.  
  191.     int                    entrynode;        // transition node at entry
  192.     int                    exitnode;        // transition node at exit
  193.     int                    nodeflags;        // transition rules
  194.     
  195.     int                    nextseq;        // auto advancing sequences
  196. } mstudioseqdesc_t;
  197.  
  198. // events
  199. typedef struct 
  200. {
  201.     int                 frame;
  202.     int                    event;
  203.     int                    type;
  204.     char                options[64];
  205. } mstudioevent_t;
  206.  
  207.  
  208. // pivots
  209. typedef struct 
  210. {
  211.     vec3_t                org;    // pivot point
  212.     int                    start;
  213.     int                    end;
  214. } mstudiopivot_t;
  215.  
  216. // attachment
  217. typedef struct 
  218. {
  219.     char                name[32];
  220.     int                    type;
  221.     int                    bone;
  222.     vec3_t                org;    // attachment point
  223.     vec3_t                vectors[3];
  224. } mstudioattachment_t;
  225.  
  226. typedef struct
  227. {
  228.     unsigned short    offset[6];
  229. } mstudioanim_t;
  230.  
  231. // animation frames
  232. typedef union 
  233. {
  234.     struct {
  235.         byte    valid;
  236.         byte    total;
  237.     } num;
  238.     short        value;
  239. } mstudioanimvalue_t;
  240.  
  241.  
  242.  
  243. // body part index
  244. typedef struct
  245. {
  246.     char                name[64];
  247.     int                    nummodels;
  248.     int                    base;
  249.     int                    modelindex; // index into models array
  250. } mstudiobodyparts_t;
  251.  
  252.  
  253.  
  254. // skin info
  255. typedef struct
  256. {
  257.     char                    name[64];
  258.     int                        flags;
  259.     int                        width;
  260.     int                        height;
  261.     int                        index;
  262. } mstudiotexture_t;
  263.  
  264.  
  265. // skin families
  266. // short    index[skinfamilies][skinref]
  267.  
  268. // studio models
  269. typedef struct
  270. {
  271.     char                name[64];
  272.  
  273.     int                    type;
  274.  
  275.     float                boundingradius;
  276.  
  277.     int                    nummesh;
  278.     int                    meshindex;
  279.  
  280.     int                    numverts;        // number of unique vertices
  281.     int                    vertinfoindex;    // vertex bone info
  282.     int                    vertindex;        // vertex vec3_t
  283.     int                    numnorms;        // number of unique surface normals
  284.     int                    norminfoindex;    // normal bone info
  285.     int                    normindex;        // normal vec3_t
  286.  
  287.     int                    numgroups;        // deformation groups
  288.     int                    groupindex;
  289. } mstudiomodel_t;
  290.  
  291.  
  292. // vec3_t    boundingbox[model][bone][2];    // complex intersection info
  293.  
  294.  
  295. // meshes
  296. typedef struct 
  297. {
  298.     int                    numtris;
  299.     int                    triindex;
  300.     int                    skinref;
  301.     int                    numnorms;        // per mesh normals
  302.     int                    normindex;        // normal vec3_t
  303. } mstudiomesh_t;
  304.  
  305. // triangles
  306. #if 0
  307. typedef struct 
  308. {
  309.     short                vertindex;        // index into vertex array
  310.     short                normindex;        // index into normal array
  311.     short                s,t;            // s,t position on skin
  312. } mstudiotrivert_t;
  313. #endif
  314.  
  315. // lighting options
  316. #define STUDIO_NF_FLATSHADE        0x0001
  317. #define STUDIO_NF_CHROME        0x0002
  318. #define STUDIO_NF_FULLBRIGHT    0x0004
  319.  
  320. // motion flags
  321. #define STUDIO_X        0x0001
  322. #define STUDIO_Y        0x0002    
  323. #define STUDIO_Z        0x0004
  324. #define STUDIO_XR        0x0008
  325. #define STUDIO_YR        0x0010
  326. #define STUDIO_ZR        0x0020
  327. #define STUDIO_LX        0x0040
  328. #define STUDIO_LY        0x0080
  329. #define STUDIO_LZ        0x0100
  330. #define STUDIO_AX        0x0200
  331. #define STUDIO_AY        0x0400
  332. #define STUDIO_AZ        0x0800
  333. #define STUDIO_AXR        0x1000
  334. #define STUDIO_AYR        0x2000
  335. #define STUDIO_AZR        0x4000
  336. #define STUDIO_TYPES    0x7FFF
  337. #define STUDIO_RLOOP    0x8000    // controller that wraps shortest distance
  338.  
  339. // sequence flags
  340. #define STUDIO_LOOPING    0x0001
  341.  
  342. // bone flags
  343. #define STUDIO_HAS_NORMALS    0x0001
  344. #define STUDIO_HAS_VERTICES 0x0002
  345. #define STUDIO_HAS_BBOX        0x0004
  346. #define STUDIO_HAS_CHROME    0x0008    // if any of the textures have chrome on them
  347.  
  348. #define RAD_TO_STUDIO        (32768.0/M_PI)
  349. #define STUDIO_TO_RAD        (M_PI/32768.0)
  350.  
  351. #endif